﻿namespace ExamV5.PaperInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ShowPaperInfo : Page
    {
        protected Button butClose;
        protected GridView DataGridInfo;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        protected Label labCheckUser;
        protected Label labEnterExamIP;
        protected Label labExamName;
        protected Label labExamTime;
        protected Label labFenDist;
        protected Label labFlag;
        protected Label labInputTime;
        protected Label labInputUser;
        protected Label labIsShow;
        protected Label labJoinExamUser;
        protected Label labJoinNum;
        protected Label labMemberFen;
        protected Label labMemoDist;
        protected Label labOutputType;
        protected Label labPaperDiff;
        protected Label labPaperFen;
        protected Label labPaperStatus;
        protected Label labPaperUseTime;
        protected Label labRubricDist;
        protected Label labStudyPlan;
        protected Label labSubjectName;
        private PublicFun publicFun_0 = new PublicFun();

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.DataItemIndex == -1)
            //{
            //    this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
            //    this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            //}
            //else
            //{
            //    e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
            //    if ((e.Row.DataItemIndex % 2) != 0)
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
            //    }
            //    else
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
            //    }
            //}
        }

        protected void DataGridInfo_PreRender(object sender, EventArgs e)
        {
            // 使用<TH>替换<TD> 
            this.DataGridInfo.UseAccessibleHeader = true;
            //HeaderRow将被<thead>包裹，数据行将被<tbody>包裹
            this.DataGridInfo.HeaderRow.TableSection = TableRowSection.TableHeader;
        }

        private void method_0()
        {
            string selectCommandText = "";
            selectCommandText = "select * from GradeReule where PaperID=" + this.int_0 + " order by ID";
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "GradeReule");
            this.DataGridInfo.DataSource = dataSet.Tables["GradeReule"].DefaultView;
            this.DataGridInfo.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
        }

        private void method_1()
        {
            try
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection.Open();
                SqlCommand command = new SqlCommand("select * from PaperInfo where ID=" + this.int_0, connection);
                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    if (!(reader["CheckMan"].ToString() != ""))
                    {
                        this.labCheckUser.Text = "无需审核";
                    }
                    else
                    {
                        this.labCheckUser.Text = this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + reader["CheckMan"].ToString() + "'", "UserName");
                    }
                    if (!(reader["StudyPlanID"].ToString() == "0"))
                    {
                        this.labStudyPlan.Text = this.publicFun_0.GetValues("select PlanName from StudyPlanInfo where ID='" + reader["StudyPlanID"].ToString() + "'", "PlanName");
                    }
                    else
                    {
                        this.labStudyPlan.Text = "暂无绑定学习任务";
                    }
                    this.labEnterExamIP.Text = reader["StartIP"].ToString() + "—" + reader["EndIP"].ToString();
                    if (reader["OutputType"].ToString() != "N")
                    {
                        this.labOutputType.Text = "全部显示";
                    }
                    else
                    {
                        this.labOutputType.Text = "一页一道";
                    }
                    if (!(reader["IsShow"].ToString() != "N"))
                    {
                        this.labIsShow.Text = "禁止切屏离开考场";
                    }
                    else
                    {
                        this.labIsShow.Text = "允许切屏离开考场";
                    }
                    if (reader["EnterTime"].ToString() == "A")
                    {
                        this.labIsShow.Text = this.labIsShow.Text + "----交卷时间以考试时长为准";
                    }
                    else
                    {
                        this.labIsShow.Text = this.labIsShow.Text + "----交卷时间有效期限截止时间为准";
                    }
                    this.labSubjectName.Text = reader["SubjectName"].ToString();
                    this.labExamName.Text = reader["ExamName"].ToString();
                    this.labPaperFen.Text = reader["PaperFen"].ToString() + "分";
                    this.labJoinNum.Text = reader["JoinExamNum"].ToString();
                    this.labMemberFen.Text = reader["MemberFen"].ToString();
                    string[] strArray2 = reader["RubricDist"].ToString().Split(new char[] { '#' });
                    string[] strArray5 = reader["FenDist"].ToString().Split(new char[] { '#' });
                    string[] strArray6 = reader["MemoDist"].ToString().Split(new char[] { '#' });
                    this.labRubricDist.Text = this.publicFun_0.GetRubricType("A", this.int_0.ToString()) + ":<font color='red'>" + strArray2[0].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("B", this.int_0.ToString()) + ":<font color='red'>" + strArray2[1].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("C", this.int_0.ToString()) + ":<font color='red'>" + strArray2[2].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("D", this.int_0.ToString()) + ":<font color='red'>" + strArray2[3].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("E", this.int_0.ToString()) + ":<font color='red'>" + strArray2[4].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("F", this.int_0.ToString()) + ":<font color='red'>" + strArray2[5].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("G", this.int_0.ToString()) + ":<font color='red'>" + strArray2[6].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("H", this.int_0.ToString()) + ":<font color='red'>" + strArray2[7].ToString() + "</font>道";
                    this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("I", this.int_0.ToString()) + ":<font color='red'>" + strArray2[8].ToString() + "</font>道";
                    if (strArray2[9].ToString().Trim() == "0")
                    {
                        this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("J", this.int_0.ToString()) + ":<font color='red'>0</font>道";
                    }
                    else
                    {
                        this.labRubricDist.Text = this.labRubricDist.Text + "<br>" + this.publicFun_0.GetRubricType("J", this.int_0.ToString()) + ":<font color='red'>" + Convert.ToString(strArray2[9].ToString().Split(new char[] { '_' }).Length) + "</font>道";
                    }
                    reader["RubricDist"].ToString().Split(new char[] { '#' });
                    reader["FenDist"].ToString().Split(new char[] { '#' });
                    reader["MemoDist"].ToString().Split(new char[] { '#' });
                    string[] strArray3 = reader["NoWriteFen"].ToString().Split(new char[] { '#' });
                    string[] strArray4 = reader["ErrorFen"].ToString().Split(new char[] { '#' });
                    this.labFenDist.Text = this.publicFun_0.GetRubricType("A", this.int_0.ToString()) + ":<font color='red'>" + strArray5[0].ToString() + "</font>分/道，未答倒扣<font color='red'>" + strArray3[0] + "</font>分/道，答错倒扣<font color='red'>" + strArray4[0] + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("B", this.int_0.ToString()) + ":<font color='red'>" + strArray5[1].ToString() + "</font>分/道，未答倒扣<font color='red'>" + strArray3[1] + "</font>分/道，答错倒扣<font color='red'>" + strArray4[1] + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("C", this.int_0.ToString()) + ":<font color='red'>" + strArray5[2].ToString() + "</font>分/道，未答倒扣<font color='red'>" + strArray3[1] + "</font>分/道，答错倒扣<font color='red'>" + strArray4[2] + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("D", this.int_0.ToString()) + ":<font color='red'>" + strArray5[3].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("E", this.int_0.ToString()) + ":<font color='red'>" + strArray5[4].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("F", this.int_0.ToString()) + ":<font color='red'>" + strArray5[5].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("G", this.int_0.ToString()) + ":<font color='red'>" + strArray5[6].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("H", this.int_0.ToString()) + ":<font color='red'>" + strArray5[7].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("I", this.int_0.ToString()) + ":<font color='red'>" + strArray5[8].ToString() + "</font>分/道";
                    this.labFenDist.Text = this.labFenDist.Text + "<br>" + this.publicFun_0.GetRubricType("J", this.int_0.ToString()) + ":<font color='red'>每题分值分布" + strArray5[9].ToString().Replace("_", " /") + "</font>分/空";
                    this.labMemoDist.Text = this.publicFun_0.GetRubricType("A", this.int_0.ToString()) + ":" + strArray6[0].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("B", this.int_0.ToString()) + ":" + strArray6[1].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("C", this.int_0.ToString()) + ":" + strArray6[2].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("D", this.int_0.ToString()) + ":" + strArray6[3].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("E", this.int_0.ToString()) + ":" + strArray6[4].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("F", this.int_0.ToString()) + ":" + strArray6[5].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("G", this.int_0.ToString()) + ":" + strArray6[6].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("H", this.int_0.ToString()) + ":" + strArray6[7].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("I", this.int_0.ToString()) + ":" + strArray6[8].ToString();
                    this.labMemoDist.Text = this.labMemoDist.Text + "<br>" + this.publicFun_0.GetRubricType("J", this.int_0.ToString()) + ":" + strArray6[9].ToString();
                    this.labExamTime.Text = reader["ExamTime"].ToString() + "分钟";
                    this.labPaperUseTime.Text = reader["PaperStartTime"].ToString() + "——" + reader["PaperEndTime"].ToString();
                    string str3 = reader["Flag"].ToString();
                    if (str3 != null)
                    {
                        if (str3 == "A")
                        {
                            this.labFlag.Text = "题目和顺序都一致";
                        }
                        else if (str3 == "B")
                        {
                            this.labFlag.Text = "题目一致但顺序不一致";
                        }
                        else if (!(str3 == "C"))
                        {
                            if (str3 == "D")
                            {
                                this.labFlag.Text = "题目和顺序都不一致";
                            }
                        }
                        else
                        {
                            this.labFlag.Text = "题目不一致";
                        }
                    }
                    str3 = reader["PaperStatus"].ToString();
                    if (str3 != null)
                    {
                        if (str3 == "A")
                        {
                            this.labPaperStatus.Text = "正规试卷";
                        }
                        else if (str3 == "B")
                        {
                            this.labPaperStatus.Text = "练习试卷";
                        }
                        else if (!(str3 == "C"))
                        {
                            if (str3 == "D")
                            {
                                this.labPaperStatus.Text = "竞赛试卷";
                            }
                        }
                        else
                        {
                            this.labPaperStatus.Text = "模拟试卷";
                        }
                    }
                    str3 = reader["PaperDiff"].ToString();
                    if (str3 != null)
                    {
                        if (str3 == "A")
                        {
                            this.labPaperDiff.Text = "难";
                        }
                        else if (str3 == "B")
                        {
                            this.labPaperDiff.Text = "较难";
                        }
                        else if (str3 == "C")
                        {
                            this.labPaperDiff.Text = "中等";
                        }
                        else if (!(str3 == "D"))
                        {
                            if (str3 == "E")
                            {
                                this.labPaperDiff.Text = "容易";
                            }
                        }
                        else
                        {
                            this.labPaperDiff.Text = "较易";
                        }
                    }
                    this.labInputUser.Text = reader["InputMan"].ToString();
                    this.labInputTime.Text = reader["InputTime"].ToString();
                }
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
                this.labJoinExamUser.Text = this.publicFun_0.GetValues("select '['+UserCode+']'+UserName as UserName from UserInfo where UserCode in(select UserCode from ExamUser where PaperID=" + this.int_0 + ")");
                this.method_2();
            }
            catch
            {
            }
        }

        private void method_2()
        {
            string str = "";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select RuleName from PaperRule where PaperID=" + this.int_0, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                str = str + "<br>" + reader["RuleName"].ToString();
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
            this.labFlag.Text = this.labFlag.Text + "<br><br><font color=red>抽题规则：</font><br>";
            if (str.Trim() == "")
            {
                str = "<br>系统随机抽,无规则";
            }
            this.labFlag.Text = this.labFlag.Text + str;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
            if ((this.httpCookie_0 != null) && !(this.httpCookie_0.Value == ""))
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                    if (!(this.publicFun_0.ReturnPaperData() != "Yes"))
                    {
                        if ((this.int_0 != 0) && (this.httpCookie_2.Value != "A"))
                        {
                            this.method_1();
                            this.method_0();
                        }
                    }
                    else
                    {
                        base.Response.Write("<script>alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')</script>");
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

